package hos.demo;

import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.activity.result.ActivityResultLauncher;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AlertDialog;

import com.blankj.utilcode.util.SizeUtils;

import cjf.app.databinding.ActivityMainBinding;
import hos.base.activity.BaseActivity;
import hos.base.dialog.AlertDialogFragment;
import hos.demo.dialog.AppCompatDialogFragmentTip;
import hos.demo.dialog.AppCompatDialogTip;
import hos.demo.dialog.BottomSheetDialogFragmentTip;
import hos.demo.dialog.BottomSheetDialogTip;
import hos.demo.dialog.DialogFragmentTip;
import hos.demo.dialog.DialogTip;

public class MainActivity extends BaseActivity {

    private ActivityMainBinding activityMainBinding;

    private String pathCamera;
    private ActivityResultLauncher<Uri> cameraLauncher;
    private ActivityResultLauncher<String> imageLauncher;

    private String pathVideo;

    private ActivityResultLauncher<String> imageMultipleLauncher;
    private ActivityResultLauncher<String> videoLauncher1;
    private ActivityResultLauncher<String[]> videoLauncher2;

    private ActivityResultLauncher<String> cameraPathLauncher;

    private ActivityResultLauncher<String> cameraUriLauncher;

    @Override
    public void onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
                             @Nullable Bundle savedInstanceState) {
        activityMainBinding = ActivityMainBinding.inflate(inflater, container, false);
        setContentView(activityMainBinding.getRoot());
        activityMainBinding.btn1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new AppCompatDialogTip(MainActivity.this)
                        .show();
            }
        });
        activityMainBinding.btn2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new DialogTip(MainActivity.this)
                        .show();
            }
        });
        activityMainBinding.btn3.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new AppCompatDialogFragmentTip()
                        .show(Gravity.BOTTOM);
            }
        });
        activityMainBinding.btn4.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new DialogFragmentTip()
                        .show();
            }
        });
        activityMainBinding.btn5.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new BottomSheetDialogFragmentTip().show();
            }
        });
        activityMainBinding.btn6.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                new BottomSheetDialogTip(MainActivity.this).show();
            }
        });
        activityMainBinding.btn7.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this)
                        .setTitle("温馨提示")
                        .setMessage("这是一个AlertDialog")
                        .setNegativeButton("确定", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {

                            }
                        });
                new AlertDialogFragment(builder).show();
            }
        });
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
//        if (resultCode != Activity.RESULT_OK) {
//            return;
//        }
//        if (requestCode == LaunchCompat.REQUEST_CODE_ALBUM) {
//            if (BuildConfig.DEBUG && data != null) {
//                Uri uri = data.getData();
//                if (uri != null) {
//                    Log.d("path", "ALBUM: " + UriUtils.uri2File(uri).getAbsolutePath());
//                }
//            }
//        }
//        if (requestCode == LaunchCompat.REQUEST_CODE_CAMERA) {
//            if (BuildConfig.DEBUG) {
//                Log.d("path", "CAMERA: " + pathCamera);
//                Log.d("path", "CAMERA: " + FileUtils.isFileExists(pathCamera));
//            }
//        }
//        if (requestCode == LaunchCompat.REQUEST_CODE_VIDEO) {
//            if (BuildConfig.DEBUG && data != null) {
//                Uri uri = data.getData();
//                if (uri != null) {
//                    Log.d("path", "VIDEO: " + UriUtils.uri2File(uri).getAbsolutePath());
//                    return;
//                }
//            }
//        }
//        if (requestCode == LaunchCompat.REQUEST_CODE_SOUND) {
//            if (BuildConfig.DEBUG && data != null) {
//                Uri uri = data.getData();
//                if (uri != null) {
//                    Log.d("path", "SOUND: " + UriUtils.uri2File(uri).getAbsolutePath());
//                    return;
//                }
//            }
//        }
//        if (BuildConfig.DEBUG && data != null) {
//            Uri uri = data.getData();
//            if (uri != null) {
//                Log.d("path", "onActivityResult: " + UriUtils.uri2File(uri).getAbsolutePath());
//            }
//        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }
}